package observer.deformation;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject extends Subject {

    List<Observer> observers = new ArrayList<>();

    public ConcreteSubject(String subjectName) {
        setName(subjectName);
    }

    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (Observer observer : observers) {
            observer.update("Concrete Subject is update");
        }
    }

    @Override
    public void change() {
        System.out.println("subject update!");
        notifyObservers();
    }
}
